{include file='common/header'}

<style>
    .input_must{ border: 1px solid #e60000; }
</style>

<div class="content">

    <div class="panel">
        <div class="logo"><img src="" /></div>
        <div class="sign">
            <h2>注册</h2>
            <form id="reg_form">
                <input type="text" name="username" class="input_must" placeholder="用户名" />
                <input type="password" name="password" class="input_must" placeholder="密码" />
                <input type="text" name="code" class="input_must" placeholder="邀请码" value="nb110" />
                <input type="text" name="nickname" placeholder="昵称" />
                <input type="text" name="qqnumber" placeholder="QQ" />
                <input type="text" name="phone" placeholder="电话" />
                <input type="text" name="realname" placeholder="真实姓名" />
                <input name="source" type="hidden" value="web" />
                <input type="button" class="btn_info" name="register" value="注册" />
            </form>
            <p class="notice">已有账号?<a href="{:url('index/login')}">现在登录</a></p>
        </div>
    </div>

</div>

{include file='common/footer'}

<script language="JavaScript">
    //注册
    $('input[name=register]').click(function(){
        var form = $('#reg_form').serializeArray();
        form.push({name:'uuid', value:navigator.userAgent});
        for(var i = 0; i < form.length; i++){
            if(form[i].name == 'username'){
                if(form[i].value.length < 3){
                    return layer.alert('用户名不能小于3位.', {icon:2});
                }
            }
            if(form[i].name == 'password'){
                if(form[i].value.length < 6){
                    return layer.alert('密码不能小于6位.', {icon:2});
                }
            }
            if(form[i].name == 'code'){
                if(form[i].value.length <= 0){
                    return layer.alert('邀请码不能为空.', {icon:2});
                }
            }
        }
        var index = layer.load(1);
        $.post("{:url('Ajax/register')}", form, function(res){
            layer.close(index);
            if(res.status == 1){
                layer.confirm('注册成功,请登录.', {icon:1}, function(){
                    location.assign("{:url('index/login')}");
                })
            }else{
                layer.msg(res.msg);
            }
        }, 'JSON');
    });
</script>